{% extends 'base.html' %}
{% block title %}Namespaces{% endblock %}
{% block nav-item-1 %}layui-nav-itemed{% endblock %}
{% block nav-this-1-2 %}layui-this{% endblock %}
{% block content %}
    <span class="layui-breadcrumb">
      <a href="#">首页</a>
      <a href="#">工作负载</a>
      <a><cite>Namespaces</cite></a>
        <a><cite>创建</cite></a>
    </span>
    <hr>

    <div class="layui-card">
        <div class="layui-card-body">

        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
          <legend>创建Namespaces</legend>
        </fieldset>

        <form class="layui-form " onclick="return false">
            <div class="layui-form-item">
                <label class="layui-form-label">名称：</label>
                <div class="layui-input-block">
                  <input type="text" name="name" lay-verify="required" lay-reqtext="名称是必填项，不能为空！" placeholder="" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">标签：</label>
                <div class="layui-input-block">
                  <input type="text" name="labels" lay-reqtext="标签是必填项，不能为空！" placeholder="示例: project=ms,app=gateway" autocomplete="off" class="layui-input">
                </div>
            </div>

<!--            <div class="layui-form-item">-->
<!--                <label class="layui-form-label">ConfigMap：</label>-->
<!--                <div class="layui-input-block">-->
<!--                    <select name="configmap"  lay-verify="required" id="configmap">-->
<!--                    </select>-->
<!--&lt;!&ndash;                  <input type="text" name="configmap" lay-verify="required" lay-reqtext="标签是必填项，不能为空！" placeholder="示例: project=ms,app=gateway" autocomplete="off" class="layui-input">&ndash;&gt;-->
<!--                </div>-->
<!--            </div>-->

<!--            <div class="layui-form-item">-->
<!--                <label class="layui-form-label">Secret：</label>-->
<!--                <div class="layui-input-block">-->
<!--                    <select name="secret"  lay-verify="required" id="secret">-->
<!--                    </select>-->
<!--                </div>-->
<!--            </div>-->

            <div class="layui-form-item">
                <div class="layui-input-block">
                  <button type="submit" class="layui-btn" lay-submit="" lay-filter="btn">立即提交</button>
                  <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>

        </form>

        </div>
    </div>


{% endblock %}

{% block js %}
<script>

layui.use(['table','form','layer'], function(){
  var table = layui.table;
  var layer = layui.layer;
  var form = layui.form;
  var $ = layui.jquery;

  // $('#ns').append('<option value=' + namespace + '>' + namespace + '</option>');
  // form.render();

  // 监听提交
  form.on('submit(btn)', function (data) {
      data = data.field;
      csrf_token = $('[name="csrfmiddlewaretoken"]').val();
      data['csrfmiddlewaretoken'] = csrf_token;
        $.ajax({
            url: '{% url 'deployment_api' %}',
            type: "POST",
            data: data,
            success: function (res) {
                if (res.code == 0) {
                    layer.msg(res.msg, {icon: 6});
                } else {
                    layer.msg(res.msg, {icon: 5})
                }
            },
            error: function () {
                layer.msg("服务器接口异常",{icon: 5})
            }
        })
  })

});
</script>

{% endblock %}